home *** CD-ROM | disk | FTP | other *** search
/ El Mac 1 / Magazine.iso / EL MAC 1 / Shareware / Graphics / AVX Video Sampler / AVX Video Sampler.dxr / 00001.ls next >
Encoding:
Text File  |  1995-09-27  |  5.2 KB  |  195 lines

  1. on startMovie
  2.   set the colorDepth to 16
  3.   initMovieSprite()
  4.   initMemory()
  5.   loadPatches()
  6. end
  7.  
  8. on initMovieSprite
  9.   global theMovie, currenRate, zoomDirection, zoomState
  10.   set currentRate to 0
  11.   set zoomDirection to -1
  12.   set zoomState to 3
  13.   set theMovie to 10
  14.   puppetSprite(10, 1)
  15.   set the stretch of sprite 10 to 1
  16.   set the immediate of sprite 10 to 1
  17.   set the height of sprite theMovie to zoomState * 120
  18.   set the width of sprite theMovie to zoomState * 160
  19. end
  20.  
  21. on initPatches
  22.   global thePatch, theMovie
  23.   set thePatch to []
  24.   set theDur to 1
  25.   if the castType of cast theMovie = #digitalVideo then
  26.     set theDur to the duration of cast 10
  27.   end if
  28.   repeat with t = 1 to 127
  29.     setAt(thePatch, t, birth(script "patch", 0, theDur, 1))
  30.   end repeat
  31. end
  32.  
  33. on loadPatches
  34.   global theMovie, thePatch, theCurrentPatch
  35.   if the castType of cast theMovie = #digitalVideo then
  36.     set theGroup to ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]
  37.     initPatches()
  38.     set theCurrentPatch to getAt(thePatch, charToNum("+"))
  39.     set theLength to the duration of cast theMovie / 10
  40.     repeat with t = 1 to 10
  41.       set theStart to (t - 1) * theLength
  42.       set theEnd to (t * theLength) - 1
  43.       if (theEnd - theStart) < 45 then
  44.         set theEnd to theStart + 45
  45.       end if
  46.       if (theEnd - theStart) > 150 then
  47.         set theEnd to theStart + 150
  48.       end if
  49.       if theEnd > the duration of cast theMovie then
  50.         set theEnd to the duration of cast theMovie
  51.       end if
  52.       set theCurrent to getAt(thePatch, charToNum(getAt(theGroup, t)))
  53.       set the startpt of theCurrent to theStart
  54.       set the endpt of theCurrent to theEnd
  55.       set the looptype of theCurrent to 0
  56.       set theCurrent to getAt(thePatch, charToNum(getAt(theGroup, t + 10)))
  57.       set the startpt of theCurrent to theStart
  58.       set the endpt of theCurrent to theEnd
  59.       set the looptype of theCurrent to 1
  60.       set theCurrent to getAt(thePatch, charToNum(getAt(theGroup, t + 20)))
  61.       set the startpt of theCurrent to theStart
  62.       set the endpt of theCurrent to theEnd
  63.       set the looptype of theCurrent to -1
  64.       set theCurrent to getAt(thePatch, charToNum(getAt(theGroup, t + 30)))
  65.       set the startpt of theCurrent to theStart
  66.       set the endpt of theCurrent to theEnd
  67.       set the looptype of theCurrent to 2
  68.     end repeat
  69.   end if
  70. end
  71.  
  72. on waitforloadmovie
  73.   global theMovie
  74.   set the keyDownScript to EMPTY
  75.   set theMovieCast to the castNum of sprite theMovie
  76.   if theMovieCast > 0 then
  77.     if the castType of cast theMovieCast = #digitalVideo then
  78.       go("play")
  79.     else
  80.       go("nomovie")
  81.     end if
  82.   else
  83.     go("nomovie")
  84.   end if
  85. end
  86.  
  87. on myFrameHook
  88.   global theCurrentPatch
  89.   checkLoop(theCurrentPatch)
  90.   go(the frame)
  91. end
  92.  
  93. on initMemory
  94.   global theMovie
  95.   if the castType of cast theMovie = #digitalVideo then
  96.     unLoadCast(theMovie)
  97.     preLoadCast(theMovie)
  98.   end if
  99. end
  100.  
  101. on setNewRate theNewRate
  102.   global currentRate, theMovie
  103.   set the movieRate of sprite theMovie to theNewRate
  104.   updateStage()
  105.   set currentRate to theNewRate
  106. end
  107.  
  108. on IMPkeydown
  109.   global theCurrentPatch, thePatch, currentRate
  110.   if the key = "[" then
  111.     setNewRate(-1 * abs(currentRate))
  112.   else
  113.     if the key = "]" then
  114.       setNewRate(abs(currentRate))
  115.     else
  116.       if the key = "-" then
  117.         setNewRate(0.89999999999999991 * currentRate)
  118.       else
  119.         if the key = "=" then
  120.           setNewRate(1.09999999999999987 * currentRate)
  121.         else
  122.           if not (the optionDown or the commandDown or the controlDown) then
  123.             set theCurrentPatch to getAt(thePatch, charToNum(the key))
  124.             playPatch(theCurrentPatch)
  125.           end if
  126.         end if
  127.       end if
  128.     end if
  129.   end if
  130.   dontPassEvent()
  131. end
  132.  
  133. on loadMovie
  134.   global theMovie
  135.   go("nomovie")
  136.   initMovieSprite()
  137.   set theFileRef to EMPTY
  138.   set theFileRef to FileIO(mnew, "?read", "MooV")
  139.   if objectp(theFileRef) then
  140.     cursor(4)
  141.     importFileInto(cast theMovie, theFileRef(mFileName))
  142.     set the preLoad of cast theMovie to 1
  143.     set the directToStage of cast theMovie to 1
  144.     set the loop of cast theMovie to 0
  145.     set the pausedAtStart of cast theMovie to 1
  146.     set the controller of cast theMovie to 0
  147.     updateStage()
  148.     initMemory()
  149.     loadPatches()
  150.     cursor(0)
  151.   else
  152.     updateStage()
  153.   end if
  154. end
  155.  
  156. on zoomMovie
  157.   global theMovie, zoomDirection, zoomState
  158.   set zoomState to zoomState + zoomDirection
  159.   if zoomState <= 1 then
  160.     set zoomState to 1
  161.     set zoomDirection to 1
  162.   else
  163.     if zoomState >= 3 then
  164.       set zoomState to 3
  165.       set zoomDirection to -1
  166.     end if
  167.   end if
  168.   set the height of sprite theMovie to 120 * zoomState
  169.   set the width of sprite theMovie to 160 * zoomState
  170.   puppetTransition(47, 1, 10, 1)
  171.   set the visible of sprite theMovie to 0
  172.   updateStage()
  173.   set the visible of sprite theMovie to 1
  174. end
  175.  
  176. on handleEBN
  177.   global theMovie, theHoldRate
  178.   set the keyDownScript to EMPTY
  179.   puppetSprite(theMovie, 0)
  180.   go("ebn")
  181. end
  182.  
  183. on handleAbout
  184.   global theMovie, theHoldRate
  185.   set the keyDownScript to EMPTY
  186.   puppetSprite(theMovie, 0)
  187.   go("about")
  188. end
  189.  
  190. on handleOK
  191.   global theMovie
  192.   go("nomovie")
  193.   initMovieSprite()
  194. end
  195.